package com.client.elements.normal.boxes;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;

public class PopupBox {
	public static Widget popupBox(){
		final FlowPanel panel = new FlowPanel();
		panel.addStyleName("master");
		panel.addStyleName("background_hellblau");

		HorizontalPanel header_panel = new HorizontalPanel();

		header_panel.add(new HTML("<b>Popupfenster</b>"));
		header_panel.addStyleName("header_blue");
		panel.add(header_panel);

		Button btn_close = new Button();
		btn_close.setStyleName("popup_close_btn");
		header_panel.add(btn_close);
		header_panel.setCellHorizontalAlignment(btn_close, HasHorizontalAlignment.ALIGN_RIGHT);

		final FlowPanel body_panel = new FlowPanel();
		body_panel.add(new HTML("Hallo Welt"));
		panel.add(body_panel);

		final DialogBox dialogBox = new DialogBox();
		VerticalPanel panelPopup = new VerticalPanel();
		panelPopup.add(panel);
		dialogBox.setWidget(panelPopup);
		dialogBox.addStyleName("gwt-DialogBoxPadding");
		panelPopup.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER);

		btn_close.addClickHandler(new ClickHandler() {
			@Override
			public void onClick(ClickEvent event) {
				dialogBox.hide();
			}
		});

		final FlowPanel panel_start = new FlowPanel();
		Button oeffnePopup = new Button();
		oeffnePopup.setSize("150px", "35px");
		panel_start.add(oeffnePopup);
		oeffnePopup.setText("Popup öffnen");
		oeffnePopup.addClickHandler(new ClickHandler() {

			@Override
			public void onClick(ClickEvent event) {
				dialogBox.center();
			}
		});
		return panel_start;
	}
}